<?php
/**
 * +----------------------------------------------------------------------
 * | 九月科技-ztuc.cn
 * +----------------------------------------------------------------------
 *                      .::::.
 *                    .::::::::.            | AUTHOR: siyu
 *                    :::::::::::           | EMAIL: ztucke@ztuc.cn
 *                 ..:::::::::::'           | DATETIME: 2020/01/31
 *             '::::::::::::'
 *                .::::::::::
 *           '::::::::::::::..
 *                ..::::::::::::.
 *              ``::::::::::::::::
 *               ::::``:::::::::'        .:::.
 *              ::::'   ':::::'       .::::::::.
 *            .::::'      ::::     .:::::::'::::.
 *           .:::'       :::::  .:::::::::' ':::::.
 *          .::'        :::::.:::::::::'      ':::::.
 *         .::'         ::::::::::::::'         ``::::.
 *     ...:::           ::::::::::::'              ``::.
 *   ```` ':.          ':::::::::'                  ::::..
 *                      '.:::::'                    ':'````..
 * +----------------------------------------------------------------------
 */
/**
 * Created by PhpStorm.
 * UserScoreLog: Administrator
 * Date: 2020/3/14
 * Time: 17:18
 */
namespace app\store\model;
use app\store\model\core\InitModel;

/**
 * 用户积分
 * Class UserScoreLog
 * @package app\model\admin
 */
class UserScoreLog extends InitModel
{
    // 定义表
    protected $name = 'user_score_log';

    // 第一自动写入时间字段
    protected $createTime = 'create_time';

    // 可用字段
    protected static $available = [
        'id',
        'user_id',
        'score',
        'before',
        'after',
        'memo',
        'create_time',
    ];   


    public static function add($post)
    {
        if (isset($post['id'])) unset($post['id']);
        $model = new self();
        return $model->save($post);
    }

    public static function edit($post)
    {
        $id = (int)$post['id'];
        $model = self::where('id',$id)->find();
        if (!$model) return false;
        return $model->save($post);
    }


    public static function del($id)
    {
        $data = self::whereIn('id', $id)->find();
        if (!$data) return false;
        self::destroy($id);
        return true;
    }


}